﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Engine.Commands;

namespace Engine.Input
{
    public delegate void DirecinalUp(Direcao dir);

    public class DirectionHelper
    {
        SimpleConcreteKeyboardInputPlayable sci1 = null;
        SimpleConcreteKeyboardInputPlayable sci2 = null;
        SimpleConcreteKeyboardInputPlayable sci3 = null;
        SimpleConcreteKeyboardInputPlayable sci4 = null;
        SimpleConcreteKeyboardInputPlayable sci5 = null;
        SimpleConcreteKeyboardInputPlayable sci6 = null;
        DirecinalUp dup;

        private void KeyStateChangecima()
        {
            dup(Direcao.CIMA);
        }
        private void KeyStateChangebaixo()
        {
            dup(Direcao.BAIXO);
        }
        private void KeyStateChangedireita()
        {
            dup(Direcao.DIREITA);
        }
        private void KeyStateChangeesquerda()
        {
            dup(Direcao.ESQUERDA);
        }
        private void KeyStateChangeVcima()
        {
            dup(Direcao.VCIMA);
        }
        private void KeyStateChangeVbaixo()
        {
            dup(Direcao.VBAIXO);
        }

        public DirectionHelper(DirecinalUp callback) : this(Keys.Up, Keys.Down, Keys.Right, Keys.Left,Keys.PageUp,Keys.PageDown, callback)
        {
            
        }

        public DirectionHelper(Keys cima, Keys baixo, Keys direita, Keys esquerda,Keys VerticalCima, Keys VerticalBaixo, DirecinalUp callback)
        {
            sci1 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, cima, KeyStateChangecima , EntityType.TOOLS);
            sci2 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, baixo, KeyStateChangebaixo, EntityType.TOOLS);
            sci3 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, direita, KeyStateChangedireita, EntityType.TOOLS);
            sci4 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, esquerda, KeyStateChangeesquerda, EntityType.TOOLS);
            sci5 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, VerticalCima, KeyStateChangeVcima, EntityType.TOOLS);
            sci6 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, VerticalBaixo, KeyStateChangeVbaixo, EntityType.TOOLS);
            dup = callback;

            BindKeyCommand k1 = new BindKeyCommand(sci1, BindAction.ADD);
            BindKeyCommand k2 = new BindKeyCommand(sci2, BindAction.ADD);
            BindKeyCommand k3 = new BindKeyCommand(sci3, BindAction.ADD);
            BindKeyCommand k4 = new BindKeyCommand(sci4, BindAction.ADD);
            BindKeyCommand k5 = new BindKeyCommand(sci5, BindAction.ADD);
            BindKeyCommand k6 = new BindKeyCommand(sci6, BindAction.ADD);
            
            CommandProcessor.getCommandProcessor().SendCommandSyncronous(k1);
            CommandProcessor.getCommandProcessor().SendCommandSyncronous(k2);
            CommandProcessor.getCommandProcessor().SendCommandSyncronous(k3);
            CommandProcessor.getCommandProcessor().SendCommandSyncronous(k4);
            CommandProcessor.getCommandProcessor().SendCommandSyncronous(k5);
            CommandProcessor.getCommandProcessor().SendCommandSyncronous(k6);

        }

        
    }

    public enum Direcao
    {
        CIMA, BAIXO, DIREITA , ESQUERDA , VCIMA , VBAIXO
    }
}
